package com.sykj.bsc.jhy.controller;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sykj.bsc.jhy.entity.Bis_nurse_type;
import com.sykj.bsc.jhy.service.Bis_nurse_typeService;

@Controller
@RequestMapping("jhy")
public class Bis_nurse_typeController {
	
	@Autowired Bis_nurse_typeService impl;
	
	//查询分类列表
	@RequestMapping("classList")
		public String selectBis_nurse_type(Bis_nurse_type bnt,Model model) {
			List<Bis_nurse_type> list = impl.selectBis_nurse_type(bnt);
			model.addAttribute("list", list);
			return "backstage/jhy/classList";
		}

	//删除分类列表记录
		@RequestMapping("delType/{type_id}")
		public String delBis_nurse_type(@PathVariable("type_id") String type_id) {
			impl.delBis_nurse_type(type_id);
			return "redirect:/jhy/classList";
		}
		
	//新增分类
		@RequestMapping("addType")
		public String addType(Map<String, String> map) {
			SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
			String str = sdf.format(new Date());
			Random random = new Random();
			int num = random.nextInt(9999)+1000;
			String type_id = str+num;
			map.put("type_id", type_id);
			return "backstage/jhy/addBis_nurse_type";
		}
		
		
		@RequestMapping("addBis_nurse_type")
		public String addBis_nurse_type(Bis_nurse_type bnt) {
			
			impl.addBis_nurse_type(bnt);
			return "redirect:/jhy/classList";
		}
		
		//修改分类
		@RequestMapping("queryTypeById/{type_id}")
		public String queryTypeById(@PathVariable("type_id") String type_id,Model model) {
			Bis_nurse_type bnt = impl.queryBytype_id(type_id);
			model.addAttribute("bnt", bnt);
			return "backstage/jhy/updateBis_nurse_type";
		}
		
		@RequestMapping("updateBis_nurse_type")
		public String updateBis_nurse_type(Bis_nurse_type bnt) {
			impl.updateBis_nurse_type(bnt);
			return "redirect:/jhy/classList";
		}
		
		
	

}
